<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>常用代码</title>
    <link rel="stylesheet" href="http://static-online.zhaogangtest.com/publicresource/css/bootstrap-table.css">
    <link rel="stylesheet" href="http://static-online.zhaogangtest.com/publicresource/css/zTreeStyle.css">
    <link rel="stylesheet" href="http://static-online.zhaogangtest.com/publicresource/control/daterangpicker/daterangepicker-bs3.css">
    <link rel="stylesheet" href="../../../resources/public/css/iconfont.min.css">
    <link rel="stylesheet" href="../../../resources/public/css/table.css">
    <link rel="stylesheet" href="../../../resources/public/css/scmstrap.css">
</head>

<body>
    <div class="leftside-sub">
        <div class="leftside-subTitle">字典类别</div>
        <div class="leftside-subinner">
            <div class="tree-wrap">
                <ul class="ztree" id="treedemo">
                </ul>
            </div>
        </div>
    </div>
    <div class="main main-sub">
        <!-- 条件区域 -->
        <!-- 按钮 -->
        <div class="operation">
<!--             <div class="conditionbtn">
                <button class="scm-btn blue">
                    <i class="anticon icon-search1"></i>查询</button>
                <button class="scm-btn resetBtn">
                    <i class="anticon icon-delete"></i>重置</button>
            </div> -->
            <!-- 按钮组 -->
            <div class="scm-btn-group fr">
                <button class="scm-btn btn-add-item">
                    <i class="anticon icon-plus"></i>添加</button>
                <button class="scm-btn  btn-adjust-item">
                    <i class="anticon icon-edit1"></i>修改</button>
            </div>
        </div>
        <div class="box-table box-tableTr">
            <table class="table table-condensed" id="table-data"></table>
        </div>
    </div>
    <!-- 添加 -->
    <div class="layer-add-item" style="display: none;">
        <div class="main">
            <!-- 条件区域 -->
            <div class="form-list form-list-btn-inner nofloat">
                <div class="group group-double-column-style ">
                    <label><b class="must">*</b>字典名称</label>
                    <div class="scm-input-wrap">
                        <input type="text" class="scm-input">
                    </div>
                </div>
                <div class="group group-double-column-style">
                    <label>状态</label>
                    <div class="scm-input-wrap mycheckradioall">
                        <label class="mycheckradio radio-popup-style"><em></em>禁用</label>
                        <label class="mycheckradio radio-popup-style  active"><em></em>启用</label>
                    </div>
                </div>
                <div class="group group-double-column-style ">
                    <label><b class="must">*</b>显示值</label>
                    <div class="scm-input-wrap">
                        <input type="text" class="scm-input" value="6">
                    </div>
                </div>
                <div class="group group-double-column-style double-column-input-style ">
                    <label>备注</label>
                    <div class="scm-input-wrap">
                        <textarea type="text" class="scm-input"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 废弃 -->
    <div class="layer-discard" style="display: none">
        <p class="layer-tips">
            <i class="anticon icon-exclamationcircle fs17 brown"></i>
            <span>确认废弃？</span>
        </p>
    </div>
    <!-- 修改 -->
    <div class="layer-adjust-item" style="display: none;">
        <div class="main">
            <!-- 条件区域 -->
            <div class="form-list form-list-btn-inner nofloat">
                <div class="group group-double-column-style ">
                    <label><b class="must">*</b>字典名称</label>
                    <div class="scm-input-wrap">
                        <input type="text" class="scm-input" value="提单超开提示">
                    </div>
                </div>
                <div class="group group-double-column-style">
                    <label>状态</label>
                    <div class="scm-input-wrap mycheckradioall">
                        <label class="mycheckradio radio-popup-style"><em></em>禁用</label>
                        <label class="mycheckradio radio-popup-style  active"><em></em>启用</label>
                    </div>
                </div>
                <div class="group group-double-column-style ">
                    <label><b class="must">*</b>显示值</label>
                    <div class="scm-input-wrap">
                        <input type="text" class="scm-input" value="6">
                    </div>
                </div>
                <div class="group group-double-column-style double-column-input-style ">
                    <label>备注</label>
                    <div class="scm-input-wrap">
                        <textarea type="text" class="scm-input"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="http://static-online.zhaogangtest.com/publicresource/js/require.js"></script>
    <script>
    require.config({
        paths: {
            "jquery": "../../../resources/public/js/jquery.min",
            "bootstrap": 'http://static-online.zhaogangtest.com/publicresource/js/bootstrap.min',
            "bootstrap-table": "../../../resources/public/js/bootstrap-table",
            "ztreecore": "http://static-online.zhaogangtest.com/publicresource/js/jquery.ztree.core.min",
            "ztreeexcheck": "http://static-online.zhaogangtest.com/publicresource/js/jquery.ztree.excheck.min",
            "moment": "http://static-online.zhaogangtest.com/publicresource/control/daterangpicker/moment.min",
            "daterangepicker": '../../../resources/public/js/daterangepicker',
            "layer": "http://static-online.zhaogangtest.com/publicresource/control/layer/layer.min",
            "public": "../../../resources/public/js/public",
            "chinese": "../../../resources/public/js/chinese",
        },
        shim: {
            "jquery": {
                exports: ['jQuery', '$']
            },
            "bootstrap": {
                deps: ["jquery"]
            },
            "bootstrap-table": {
                deps: ["jquery", "bootstrap"]
            },
            "ztreecore": {
                deps: ["jquery"],
            },
            "ztreeexcheck": {
                deps: ["jquery", "ztreecore"],
            },

            "moment": {
                deps: ["jquery"],
            },
            "daterangepicker": {
                deps: ["jquery", "moment"],
                exports: "daterangepicker"
            },
            "layer": {
                deps: ["jquery"],
                exports: "layer"
            },


            "public": {
                deps: ["jquery", "bootstrap-table", "moment", "daterangepicker"]
            },

            "chinese": {
                deps: ["jquery", "bootstrap-table"],
            },

        }
    });
    require(["public", "layer", "chinese", "ztreeexcheck"], function() {
        layer.config({
            path: 'http://static-online.zhaogangtest.com/publicresource/control/layer/'
        });
        $(function() {
            var page = {
                $table: $('#table-data'),
                init: function() {
                    this.bootstrapTable();
                    this.fn_layer();
                    this.fn_getTrData();
                    this.fn_zTree();

                    $(window).resize(function() {
                        page.$table.bootstrapTable('resetView', {
                            height: page.getHeight()
                        });
                    });
                    $.daterangepicker("#datepicker,#datepicker1,#datepicker2");
                },

                fn_layer: function() {
                    // 添加
                    $(document).on("click", ".btn-add-item", function() {
                        layer.open({
                            type: 1, //page层
                            area: ['700px', '315px'],
                            title: '新增',
                            shadeClose: false,
                            btn: ['保存', '取消'],
                            shade: 0.01, //遮罩透明度
                            moveType: 1, //拖拽风格，0是默认，1是传统拖动
                            shift: -1, //0-6的动画形式，-1不开启
                            content: $('.layer-add-item'),
                            skin: "skin-searchMore skin-overflow",
                            yes: function() {
                                $('.layer-add').find('form').submit();
                            }
                        })
                    });
                    // 修改
                    $(document).on("click", ".btn-adjust-item", function() {
                        layer.open({
                            type: 1, //page层
                            area: ['700px', '315px'],
                            title: '修改',
                            shadeClose: false,
                            btn: ['保存', '取消'],
                            shade: 0.01, //遮罩透明度
                            moveType: 1, //拖拽风格，0是默认，1是传统拖动
                            shift: -1, //0-6的动画形式，-1不开启
                            content: $('.layer-adjust-item'),
                            skin: "skin-searchMore skin-overflow",
                            yes: function() {
                                $('.layer-add').find('form').submit();
                            }
                        })
                    });
                    // 废弃
                    $(document).on('click', '.btn-discard', function() {
                        var index = layer.open({
                            type: 1, //page层
                            area: ['400px', 'auto'],
                            title: '提示',
                            shadeClose: false,
                            btn: ['确定', '取消'],
                            shade: 0.01, //遮罩透明度
                            moveType: 1, //拖拽风格，0是默认，1是传统拖动
                            shift: -1, //0-6的动画形式，-1不开启
                            content: $('.layer-discard'),
                            skin: "skin-searchMore",
                            // 确定
                            yes: function(index) {
                                layer.close(index)


                            },
                            // 取消
                            btn2: function() {


                            }
                        })
                    })
                },
                bootstrapTable: function() {
                    page.$table.bootstrapTable({
                        pagination: true, //在表格底部显示分页工具栏
                        pageSize: 50,
                        pageNumber: 1,
                        pageList: [10, 25, 50, 100],
                        height: this.getHeight(),
                        showFooter: false,
                        showColumns: false,
                        showRefresh: false,
                        //                    showToggle:true,
                        search: false,
                        //                    showPaginationSwitch:true,
                        // detailView: true,
                        // detailFormatter: this.showChild,
                        // onExpandRow: this.expandRow,
                        // onCollapseRow: this.collapseRow,
                        locales: 'zh-CN',

                        uniqueId: "id",
                        fixedColumns: true,
                        url: '../data/erp/tablelist-common-code.json',
                        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）

                        columns: [{
                            "field": "n0",
                            "title": "字典编码",
                        }, {
                            "field": "n1",
                            "title": "字典名称",

                        }, {
                            "field": "n2",
                            "title": "字典值",
                        }, {
                            "field": "n3",
                            "title": "状态",

                        }, {
                            "field": "n4",
                            "title": "备注",

                        }]
                    });
                },
                // 表格高度
                getHeight: function() {
                    var height = public.fn_tableHeight()
                    return $(window).height() - height;
                },
                //获取选中行数据
                fn_getTrData: function() {
                    $(document).on('click', '.box-tableTr .table tbody>tr', function() {
                        var id = $(this).closest('tr').attr('data-uniqueid');
                        if ($(this).hasClass('active')) {
                            var data = page.$table.bootstrapTable(
                                'getRowByUniqueId', id); //获取选中行的数据
                            console.log(data);

                        }

                    })

                },
                fn_zTree: function() {
                    var zNodes = [{
                            name: "资金管理",
                            open: false,
                            click: false,
                            nocheck: true,

                            children: [{
                                name: '商贸物流',
                                click: false,
                                open: false,
                                nocheck: true,
                                children: [{
                                    name: '销售类型',
                                }]
                            }, {
                                name: '常用属性',
                                click: false,
                                open: false,
                                nocheck: true,
                                children: [{
                                    name: '允许超开吨数',
                                }, {
                                    name: '分站库存允许为负的吨数',
                                }, {
                                    name: '非生产产品类型',
                                }, {
                                    name: '检验员',
                                }, {
                                    name: '提单可以超开订单数量',
                                }, {
                                    name: '提单超开订单吨数',
                                }, {
                                    name: '提单可以超开订单吨数',
                                }, {
                                    name: '提单类型',
                                }, {
                                    name: '订单可以超开合同吨数',
                                }, {
                                    name: '产品类型',
                                }, {
                                    name: '数量单位',
                                }, {
                                    name: '班组',
                                }, {
                                    name: '班组喷码',
                                }, {
                                    name: '重量单位',
                                }, {
                                    name: '仓库类型',
                                }, {
                                    name: '车间',
                                }]
                            }, {
                                name: '财务管理',
                                click: false,
                                open: false,
                                nocheck: true,
                                children: [{
                                    name: '成本管理',
                                }]
                            }, {
                                name: '在线化属性',
                                click: false,
                                open: false,
                                nocheck: true,
                                children: [{
                                    name: '在线化可售数量',
                                }, {
                                    name: '在线化可售重量',
                                }, {
                                    name: '在线化合同下载限制',
                                }, {
                                    name: '在线化合同打印限制',
                                }, {
                                    name: '在线化文件存储路径',
                                }, {
                                    name: '订单审批次数',
                                }, {
                                    name: '全局价格调整参数',
                                }, {
                                    name: '商城可下单开始时间',
                                }, {
                                    name: '商城可下单结束时间',
                                }, {
                                    name: '短信开关',
                                }]
                            }],
                        }
                    ]
                    var setting = {
                        view: {
                            showLine: false,
                            showIcon: false,
                            fontCss: setFontCss
                        },
                        callback: {
                            // beforeClick: beforeClick,
                        }
                    };

                    function beforeClick(treeId, treeNode, clickFlag) {
                        return (treeNode.click != false);
                    }
                    // 设置节点文字颜色
                    function setFontCss(treeId, treeNode) {
                        return treeNode.level == 0 ? {
                            "font-size": "14px"
                        } : {};
                    };

                    $(document).ready(function() {
                        $.fn.zTree.init($("#treedemo"), setting, zNodes);
                    });
                },

            }
            page.init();
        })

    })
    </script>
</body>

</html>